
package com.tuling.code.io.bio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class TimeClient {
	public static void main(String[] args) {
		Socket socket = null;
		int port = 8080;
		BufferedReader in = null;
		PrintWriter out = null;
		
		try {
			socket = new Socket("192.168.1.101", port);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			
			//boolean autoFlush = true;
			
			out = new PrintWriter(socket.getOutputStream(),true);
			
			out.println("QUERY TIME ORDER");
			
			System.out.println("Send order 2 server succeed!");
			String resp = in.readLine();
			System.out.println("Now is :"+resp);
			
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		} finally {
			if(null != out){
				out.close();
			}
			
			if(in != null){
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			
			if(socket != null){
				try {
					socket.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
